import 'dart:io';
import 'package:lovify/core/network/model/response_entity.dart';
import 'package:lovify/core/utils/api_client.dart';

class FileService {
  final ApiClient _apiClient = ApiClient();

  Future<ResponseEntity<String>> upload(File file,
      {Function(int, int)? onProgress}) async {
    final response = await _apiClient.file(
      '/file/upload',
      filePath: file.path,
      onProgress: onProgress,
    );
    return ResponseEntity.fromJson(
      response,
      (json) => json as String,
    );
  }

  Future<ResponseEntity<String>> decode(File file,
      {Function(int, int)? onProgress}) async {
    final response = await _apiClient.file(
      '/qrcode/dec',
      filePath: file.path,
      onProgress: onProgress,
    );
    return ResponseEntity.fromJson(
      response,
      (json) => json as String,
    );
  }
}
